package com.ck.easy.easyExcel;

import com.ck.easy.excel.EasyExcelUtil;
import com.ck.easy.factory.EasyExcelWriterFactory;
import com.ck.easy.vo.ScoreDataVo;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;

public class ImportExcel {
    @Test
    void ImportTest(){
        //生成用来测试导出读取excel数据的成绩汇总表
        String fileName = UUID.randomUUID().toString();
        String path = "F:\\成绩汇总表.xls";    //导出路径
        List<ScoreDataVo> senior1 = new ArrayList<>();
        List<ScoreDataVo> senior2 = new ArrayList<>();
        List<ScoreDataVo> senior3 = new ArrayList<>();
        Random random = new Random();
        //初始化成绩表数据
        for(int i = 1;i<=1000;i++){
            ScoreDataVo score1 = new ScoreDataVo(i,"高一","学生"+i,random.nextInt(100)+50,random.nextInt(100)+50,random.nextInt(130)+20,random.nextInt(200)+100);
            ScoreDataVo score2 = new ScoreDataVo(i,"高二","学生"+i,random.nextInt(100)+50,random.nextInt(100)+50,random.nextInt(130)+20,random.nextInt(200)+100);
            ScoreDataVo score3 = new ScoreDataVo(i,"高三","学生"+i,random.nextInt(100)+50,random.nextInt(100)+50,random.nextInt(130)+20,random.nextInt(200)+100);
            senior1.add(score1);
            senior2.add(score2);
            senior3.add(score3);
        }
        //导出Excel，链式添加sheet
        EasyExcelWriterFactory res = EasyExcelUtil.writeWithSheets(path)
                .writeModel(ScoreDataVo.class, senior1, "高一成绩表")
                .writeModel(ScoreDataVo.class, senior2, "高二成绩表")
                .writeModel(ScoreDataVo.class, senior3, "高三成绩表");

        res.finish();	//关闭流，不然会报错
    }
}
